package com.atguigu.guli.service.base.exception;

import com.atguigu.guli.service.base.result.ResultCodeEnum;
import lombok.Getter;

@Getter
public class GuliException extends RuntimeException {
    //状态码
    private Integer code;

    //接收状态码和消息
    public GuliException(Integer code,String message){
        super(message);
        this.code = code;
    }

    //接收枚举类型
    public GuliException(ResultCodeEnum resultCodeEnum){
        super(resultCodeEnum.getMessage());
        this.code = resultCodeEnum.getCode();
    }

    public GuliException(ResultCodeEnum excelDataImportError, Exception e) {
        super(excelDataImportError.getMessage());
        this.code = excelDataImportError.getCode();
        e.printStackTrace();
    }

    @Override
    public String toString() {
        return "GuliException{" +
                "code=" + code +
                ", message=" + this.getMessage() +
                '}';
    }
}
